[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  BREAK/RECOVER     May not return code block.

  Clipper Version  1.29 dtd 04/15/91.

  Problem Statement

  The BREAK / RECOVER USING methodology may not return a code block.
  Here's one example from Jeff Cheney [72570,675] :

    *********************
    ** PRNERROR.PRG    **
    ** compile with /N **
    *********************
    FUNCTION prnError
    LOCAL lErrorObj
    SET DEVICE TO PRINT
    DO WHILE .T.
      // begin trapping printer errors
      BEGIN SEQUENCE
        // make sure printer is turned off to invoke handler
        @ 1,0 SAY "!!!!!"
        RECOVER USING lErrorObj
        // set a break point here and have a look at lErrorObj with
        //   Monitor Locals under the debugger, it's NOT AN OBJECT anymore!
        IF lErrorObj:cargo
          LOOP
        ELSE
          EXIT
        ENDIF
      END SEQUENCE
    ENDDO
    SET DEVICE TO SCREEN
    RETURN NIL

    **********************
    ** ERROR.prg        **
    ** compile with /N  **
    **********************
    #include "Error.Ch"

    FUNCTION errorsys
    // set up new error handler
    ERRORBLOCK( { | lErrorObj | ErrorTest( lErrorObj ) } )
    RETURN NIL

    FUNCTION ErrorTest( lErrorObj )
    LOCAL lChoice,lSetDevice
    IF lErrorObj:genCode == EG_PRINT .AND. lErrorObj:canRetry
      lSetDevice := SET( _SET_DEVICE,"SCREEN" )
      lChoice := ALERT( "Printer Error", { "Abort","Retry","Restart" } )
      SET( _SET_DEVICE,lSetDevice )
      IF lChoice <> 2
        lErrorObj:cargo := ( lChoice == 3 )
        BREAK                  // I also tried BREAK( lChoice == 3 )
      ENDIF                    //   and BREAK( lErrorObj ) but it acts
    ENDIF                      //   the same way
    RETURN ( lChoice == 2 )

  Cause

  Unknown.

  Work Around(s)

  Code would be unique to each incidence.


This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson